package com.cyd.demo;

import com.cyd.demo.entity.User;
import com.cyd.demo.service.JdbcTemplateServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javax.sql.DataSource;

/**
 * @author keyer
 */
@SpringBootApplication
public class SpringbootS1BeanApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootS1BeanApplication.class, args);
        DataSource dataSource = context.getBean(DataSource.class);
        System.out.println("-----------------连接池数据源--------------");
        System.out.println(dataSource);

        System.out.println("-----------------项目启动-----------------");
        String port = context.getEnvironment().getProperty("server.port");
        System.out.println("http://localhost:" + port);

        JdbcTemplateServiceImpl dao = context.getBean(JdbcTemplateServiceImpl.class);
        User user = dao.getUser(1L);
        System.out.println(user);
    }

}
